<template>
  <div class="login-container">
    <div class="login-wrapper">
      <!-- 欢迎信息放在左侧 -->
      <div class="info-container">
        <div class="welcome-text">
          <h2>欢迎使用物流订单系统</h2>
          <p>高效便捷的物流订单管理平台，助力您的物流运营更智能、更便捷。</p>
          <div class="features">
            <div class="feature-item">
              <el-icon><Document /></el-icon>
              <span>订单跟踪</span>
            </div>
            <div class="feature-item">
              <el-icon><Van /></el-icon>
              <span>配送管理</span>
            </div>
            <div class="feature-item">
              <el-icon><MapLocation /></el-icon>
              <span>地图导航</span>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 表单内容放在右侧 -->
      <div class="form-container">
        <div class="logo-area">
          <el-avatar shape="square" :size="48" class="logo-avatar">L</el-avatar>
          <h1 class="system-title">物流订单系统</h1>
        </div>
        
        <div class="auth-container">
          <!-- 固定的标签页头部 -->
          <div class="tabs-header">
            <el-tabs v-model="activeTab" type="border-card">
              <el-tab-pane label="登录" name="login"></el-tab-pane>
              <el-tab-pane label="注册" name="register"></el-tab-pane>
            </el-tabs>
          </div>
          
          <!-- 可滚动的表单内容区域 -->
          <div class="tab-content-wrapper">
            <div v-if="activeTab === 'login'" class="tab-content">
              <LoginForm />
            </div>
            <div v-else-if="activeTab === 'register'" class="tab-content">
              <RegisterForm />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { Document, Van, MapLocation } from '@element-plus/icons-vue'
import LoginForm from './components/LoginForm.vue'
import RegisterForm from './components/RegisterForm.vue'

const activeTab = ref('login')
</script>

<style scoped>
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8edf5 100%);
}

.login-wrapper {
  display: flex;
  width: 900px;
  min-height: 600px;
  height: 650px; /* 固定高度 */
  background-color: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  flex-direction: row; /* 确保是水平排列 */
}

.form-container {
  width: 50%;
  height: 650px; /* 固定高度 */
  padding: 40px;
  display: flex;
  flex-direction: column;
  order: 2; /* 表单放在右侧 */
  background-color: #ffffff;
  border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.logo-area {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}

.logo-avatar {
  background: linear-gradient(135deg, #42b983 0%, #33a06f 100%);
}

.system-title {
  margin-left: 16px;
  font-size: 24px;
  color: #2c3e50;
  font-weight: 600;
}

.auth-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: calc(100% - 70px); /* 减去logo区域高度 */
}

.tabs-header {
  /* 标签头部固定 */
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #ffffff;
}

.tab-content-wrapper {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 30px; /* 底部留白 */
  padding-right: 15px; /* 为滚动条腾出右侧空间 */
}

.tab-content {
  padding: 30px 0 20px; /* 顶部和底部都留白 */
  margin-right: 5px; /* 内容与滚动条之间的间距 */
}

/* 自定义滚动条样式 */
.tab-content-wrapper::-webkit-scrollbar {
  width: 4px;
  margin-left: 10px; /* 尝试增加左边距 */
}

.tab-content-wrapper::-webkit-scrollbar-thumb {
  background-color: rgba(144, 147, 153, 0.3);
  border-radius: 4px;
}

.tab-content-wrapper::-webkit-scrollbar-track {
  background-color: transparent;
  margin-right: 0;
  margin-left: 10px; /* 滚动条轨道左边距 */
}

/* 创建滚动条容器 */
.tab-content-wrapper {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(144, 147, 153, 0.3) transparent; /* Firefox */
  position: relative;
}

/* 为不支持自定义滚动条的浏览器提供备选方案 */
@supports not (scrollbar-width: thin) {
  .tab-content-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 15px; /* 滚动条右侧空白区域 */
    height: 100%;
    background-color: transparent;
    pointer-events: none;
  }
}

:deep(.el-tabs) {
  box-shadow: none;
}

:deep(.el-tabs--border-card) {
  border: none;
  box-shadow: none;
  background-color: transparent;
}

:deep(.el-tabs__header) {
  background-color: transparent;
  border-bottom: 1px solid #e8e8e8;
}

:deep(.el-tabs__nav) {
  border: none !important;
}

:deep(.el-tabs__item) {
  border: none !important;
  height: 50px;
  font-size: 16px;
  color: #606266;
}

:deep(.el-tabs__item.is-active) {
  color: #409eff;
  font-weight: 600;
}

:deep(.el-tabs__content) {
  display: none; /* 隐藏原始内容区域 */
}

.info-container {
  width: 50%;
  height: 650px; /* 固定高度与表单容器一致 */
  background: linear-gradient(135deg, #409EFF 0%, #2d78c3 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 50px;
  position: relative;
  overflow: hidden;
  order: 1; /* 欢迎信息放在左侧 */
}

.welcome-text {
  position: relative;
  z-index: 10;
}

.welcome-text h2 {
  font-size: 32px;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.welcome-text p {
  opacity: 0.9;
  margin-bottom: 30px;
  line-height: 1.7;
  font-size: 16px;
}

.features {
  display: flex;
  flex-direction: column;
  gap: 25px;
  margin-top: 40px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.feature-item .el-icon {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  padding: 10px;
  font-size: 20px;
}

.feature-item span {
  font-size: 17px;
  font-weight: 500;
}

.info-container::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(rgba(255, 255, 255, 0.1) 8%, transparent 8%);
  background-position: 0 0;
  background-size: 30px 30px;
  opacity: 0.3;
}

@media (max-width: 900px) {
  .login-wrapper {
    width: 100%;
    height: auto; /* 移动端下自适应高度 */
    min-height: 100vh;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
  }

  .form-container,
  .info-container {
    width: 100%;
    height: auto; /* 移动端下自适应高度 */
    order: 0; /* 重置顺序 */
  }

  .info-container {
    min-height: 300px; /* 移动端下最小高度 */
    padding: 30px;
  }
  
  .form-container {
    padding: 20px;
    min-height: 500px; /* 移动端下最小高度 */
  }
  
  .auth-container,
  .tab-content-wrapper {
    height: auto; /* 移动端下自适应高度 */
  }
  
  .welcome-text h2 {
    font-size: 24px;
  }
  
  .feature-item .el-icon {
    padding: 8px;
    font-size: 16px;
  }
}
</style> 